//
//  DHTabBarButton.m
//  lotteryticket
//
//  Created by DH on 16/4/16.
//  Copyright © 2016年 http://blog.sina.com.cn/dhios All rights reserved.
//

#import "DHTabBarButton.h"

@implementation DHTabBarButton

- (instancetype)init
{
    if (self = [super init]) {
        self.imageView.contentMode = UIViewContentModeCenter;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return self;
}

- (CGFloat)imageViewRadio
{
    if (_imageViewRadio <= 0 || _imageViewRadio > 1) {
       return  0.6;
    } else {
        return _imageViewRadio;
    }
}

// forbid button highlighted
- (void)setHighlighted:(BOOL)highlighted
{
    
}

// if you want to custom button ,you can achieve under two methods
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat w = contentRect.size.width;
    CGFloat h = contentRect.size.height * self.imageViewRadio;
    return (CGRect){x, y, w, h};
}
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat x = 0;
    CGFloat y = contentRect.size.height * self.imageViewRadio;
    CGFloat w = contentRect.size.width;
    CGFloat h = contentRect.size.height * (1 - self.imageViewRadio);
    return (CGRect){x, y, w, h};
}
@end
